<?php
namespace Little\Controller;
header("Content-type: text/html; charset=utf-8");
use Think\Controller;

//**********************删除****************************

class DelController extends Controller
{
    //购物车商品删除
    public function index()
    {
        $id       = I('id');
        $user_id  = I('user_id');
        if ($id) {
            $res = del("cars", "id = {$id}");
            if ($res) {
                $cars = sels("cars", " * ", "user_id = {$user_id}");
                if ($cars) {
                    foreach ($cars as $k => $v) {
                        $goods = sel("goods", "banner,name,lei", "id = {$v['goods_id']}");
                        //店铺名称
                        //$sto                    = sel("stores","store_name","id = {$goods['stores_id']}");
                        $cars[$k]['ids'] = $k;
                        //$cars[$k]['store_name']= $sto['store_name'];
                        $cars[$k]['store_name'] = "寻爱";
                        $cars[$k]['shop_img']   = IMGS . $goods['banner'];
                        $cars[$k]['shop_name']  = $goods['name'];
                        $cars[$k]['shop_num']   = $v['nums'];
                        $cars[$k]['selected']   = true;
                        $cars[$k]['pan']         = 1;
                        $cars[$k]['shop_money'] = $v['moneys'];
                    }
                } else {
                    $cars = 1;
                }
                echo json_encode(array("info" => $cars));
            } else {
                echo 2;
            }
        } else {
            echo 2;
        }
    }
}